package cn.baiyang.rocketmq.spring.autoconfigure;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * RocketMQ Properties
 *
 * @author hongzhu
 * @version V1.0
 * @since 2023-07-24 17:15
 */
@ConfigurationProperties(prefix = "rocketmq-java")
public class RocketMQProperties {

    /**
     * 地址
     */
    private String endpoints;
    /**
     * 账户名
     */
    private String accesskey;
    /**
     * 账户密钥
     */
    private String secretkey;
    /**
     * 是否开启ssl
     */
    private Boolean enableSsl = true;
    /**
     * RocketMQ连接超时时间，单位秒；默认180秒
     */
    private int requestTimeout = 180;

    private Producer producer;

    public String getEndpoints() {
        return endpoints;
    }

    public void setEndpoints(String endpoints) {
        this.endpoints = endpoints;
    }

    public String getAccesskey() {
        return accesskey;
    }

    public void setAccesskey(String accesskey) {
        this.accesskey = accesskey;
    }

    public String getSecretkey() {
        return secretkey;
    }

    public void setSecretkey(String secretkey) {
        this.secretkey = secretkey;
    }

    public Boolean getEnableSsl() {
        return enableSsl;
    }

    public void setEnableSsl(Boolean enableSsl) {
        this.enableSsl = enableSsl;
    }

    public int getRequestTimeout() {
        return requestTimeout;
    }

    public void setRequestTimeout(int requestTimeout) {
        this.requestTimeout = requestTimeout;
    }

    public Producer getProducer() {
        return producer;
    }

    public void setProducer(Producer producer) {
        this.producer = producer;
    }

    /**
     * Nested Producer
     */
    public static class Producer {
        /**
         * 主题列表, 多个值以逗号','分隔
         */
        private String topics;
        /**
         * 重试次数，默认为3
         */
        private Integer maxAttempts = 3;
        /**
         * 流控功能开启的开关
         */
        private Boolean enableRateLimit = true;

        public Boolean getEnableRateLimit() {
            return enableRateLimit;
        }

        public void setEnableRateLimit(Boolean enableRateLimit) {
            this.enableRateLimit = enableRateLimit;
        }

        public String getTopics() {
            return topics;
        }

        public void setTopics(String topics) {
            this.topics = topics;
        }

        public Integer getMaxAttempts() {
            return maxAttempts;
        }

        public void setMaxAttempts(Integer maxAttempts) {
            this.maxAttempts = maxAttempts;
        }
    }

}
